import BaseXform from '../base-xform';

class WorkbookPivotCacheXform extends BaseXform {
    render(xmlStream, model) {
        xmlStream.leafNode('pivotCache', {
            cacheId: model.cacheId,
            'r:id': model.rId,
        });
    }

    parseXmlObject(node) {
        if (node._name === 'pivotCache') {
            this.model = {
                cacheId: node._attributes.cacheId,
                rId: node._attributes['r:id'],
            };
            return true;
        }
        return false;
    }

    parseOpen(node) {
        if (node.name === 'pivotCache') {
            this.model = {
                cacheId: node.attributes.cacheId,
                rId: node.attributes['r:id'],
            };
            return true;
        }
        return false;
    }

    parseText() {
    }

    parseClose() {
        return false;
    }
}

export default WorkbookPivotCacheXform;
